import { HttpServer } from "../utils/request";

export const FetchUserInfo = <T>(parentAddress: any) => {
  return HttpServer<T>("/user/info", { parentAddress: parentAddress }, "get");
};

export const Register = <T>(parentAddress: any) => {
  return HttpServer<T>("/user/register", { user: { parentAddress: parentAddress } }, "post");
};

// 获取节点信息
export const Async_nodeinfo = <T>() => {
  return HttpServer<T>("/common/nodeinfo", {}, "get");
};

// 获取已邀请人数
export const Async_recommendNum = <T>(Address: string) => {
  return HttpServer<T>("/user/recommendNum", { Address: Address }, "get");
};

// 排行榜
export const Async_ranking = <T>() => {
  return HttpServer<T>("/user/ranking", {}, "get");
};

// nft 资产
export const Async_nfts = <T>(data) => {
  return HttpServer<T>(`/nft/recordList?page=${data.page}&size=${data.size}`, {}, "get");
};

// nft 赎回
export const Async_redemption = <T>(data) => {
  return HttpServer<T>("/nft/redemption", data, "post");
};

// nft 合成
export const Async_craft = <T>(data:string[]) => {
  return HttpServer<T>("/nft/craft", {codes:data}, "post");
};

// 公益捐赠
export const Async_donate = <T>(data) => {
  return HttpServer<T>("/user/donate", data, "post");
};

// 我的资产
export const Async_myWallet = <T>() => {
  return HttpServer<T>("/user/myWallet", {}, "get");
};

// 我的团队
export const Async_myTeam = <T>() => {
  return HttpServer<T>("/user/myTeam", {}, "get");
};

// 获取被推荐列表
export const Async_recommend = <T>(data) => {
  let url = `/user/recommend?page=${data.page}&size=${data.size}`
  if (data.all === true || data.all === false) {
    url = `${url}&all=${data.all}`
  }
  return HttpServer<T>(url, {}, "get");
};

// 领取宝箱
export const Async_getCoin = <T>() => {
  return HttpServer<T>(`/user/getCoin`, {}, "get");
};

// 资金变动记录
export const Async_cashList = <T>(data) => {
  return HttpServer<T>(`/cash/list?page=${data.page}&size=${data.size}&coin=${data.coin}`, {}, "get");
};

// 领取
export const Async_withdraw = <T>(data) => {
  return HttpServer<T>("/cash/withdraw", data, "post");
};

// 领取记录
export const Async_withdrawList = <T>(data) => {
  return HttpServer<T>(`/cash/withdrawList?page=${data.page}&size=${data.size}`, {}, "get");
};

// 获取节点信息
export const Async_takeUSDT = <T>() => {
  return HttpServer<T>("/user/getNodeBonus", {}, "get");
};